<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    button.active{
      background-color: rgb(217, 178, 217);
    }
    .content{
      width: 200px;
      height: 200px;
      font-size: 50px;
      text-align: center;
      line-height: 200px;
      border: 1px solid #333;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="switchTab(0)" :class="{active: activeIndex === 0}">标题1</button>
    <button @click="switchTab(1)" :class="{active: activeIndex === 1}">标题2</button>
    <button @click="switchTab(2)" :class="{active: activeIndex === 2}">标题3</button>
    <div class="content" v-show="activeIndex === 0">内容1</div>
    <div class="content" v-show="activeIndex === 1">内容2</div>
    <div class="content" v-show="activeIndex === 2">内容3</div>
  </div> 
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
      data(){
        return {
          activeIndex: 0
        }
      },
      methods: {
        switchTab(index) {
          this.activeIndex = index;
        }
      }
    })
    app.mount('#app')
  </script>
</body>
</html>